/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.service.impl;

import com.icinfo.cloud.provider.common.utils.BaseUtil;
import com.icinfo.cloud.provider.punish.evaluate.dto.EvaluateRecordDto;
import com.icinfo.cloud.provider.punish.evaluate.model.EvaluateRecord;
import com.icinfo.cloud.provider.punish.mapper.EvaluateRecordMapper;
import com.icinfo.cloud.provider.punish.service.IEvaluateRecordService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 描述:  case_evaluate_record 对应的Service接口实现类.<br>
 *
 * @author framework generator
 * @date 2023年02月07日
 */
@Service
public class EvaluateRecordServiceImpl extends MyBatisServiceSupport implements IEvaluateRecordService {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(EvaluateRecordServiceImpl.class);

    @Autowired
    private EvaluateRecordMapper evaluateRecordMapper;

    /**
     * 【V1.0.0】描述：移动端案件评价保存接口
     *
     * @param evaluateRecordDto
     * @return {@link Result <String>}
     * @author gll
     */
    @Override
    public Result saveEvaluateInfo(EvaluateRecordDto evaluateRecordDto) {
        try {
            EvaluateRecord evaluateRecord = new EvaluateRecord();
            BeanUtils.copyProperties(evaluateRecordDto, evaluateRecord);
            evaluateRecord.setId(BaseUtil.createUid());
            evaluateRecord.setEvaluateTime(new Date());
            if (evaluateRecordMapper.insertSelective(evaluateRecord) > 0) {
                return Result.success("案件评价保存成功");
            }
            return Result.error("案件评价保存失败");
        } catch (Exception e) {
            logger.info("案件评价保存异常" + e);
            return Result.error("案件评价保存异常" + e);
        }

    }
}
